//
//  KYCycleModel.m
//  kuaiyi
//
//  Created by 杨亮 on 16/3/12.
//  Copyright © 2016年 kuaiyi. All rights reserved.
//

#import "KYCycleModel.h"
#import "KYNetTool.h"
#import <MJExtension.h>

@implementation KYCycleModel
+(void)cycleWithUrl:(NSString *)url parma:(NSDictionary *)parma success:(void(^)(NSArray *))success failure:(void(^)(NSError *error))failure{
    [[KYNetTool shareManager] POST:url parameters:parma progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dictData = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
//        NSLog(@"%@",dictData);
        NSArray *array = dictData[@"data"][@"banners"];
//        NSLog(@"banner=%@",array);
        NSMutableArray *tempArray = [NSMutableArray array];
        for (NSDictionary *dict in array) {
            KYCycleModel *model = [KYCycleModel mj_objectWithKeyValues:dict];
            [tempArray addObject:model];
//            NSLog(@"%@",tempArray);
        }
        success(tempArray.copy);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}
@end
